package com.yn.service.zy.model.dto;

import com.yn.common.model.zy.TDeviceInfoDO;
import com.yn.common.utils.BeanUtils;
import com.yn.common.utils.MoneyUtils;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import java.math.BigDecimal;
import java.util.Objects;

/**
 * @ClassName: TDeviceInfoInDTO
 * @Description: 设备入参
 * @Author: ym
 * @Date: 2025/5/8 16:55
 **/
@Data
public class TDeviceInfoInDTO {
    /** 设备信息id */
    @ApiModelProperty("设备信息id")
    private Integer deviceInfoId;
    /** 设备名称 */
    @ApiModelProperty("设备名称")
    private String deviceName;
    /** 设备图片 */
    @ApiModelProperty("设备图片")
    private String deviceImageUrl;
    /** 设备介绍 */
    @ApiModelProperty("设备介绍")
    private String deviceIntro;
    /** 设备租金 */
    @ApiModelProperty("设备租金")
    private BigDecimal deviceRent;
    /** 单位(次/天)字典 */
    @ApiModelProperty("单位(次/天)字典")
    private String rentalUnit;
    /** 设备押金 */
    @ApiModelProperty("设备押金")
    private BigDecimal equipmentDeposit;
    /** 备注 */
    @ApiModelProperty("备注")
    private String remark;

    public static TDeviceInfoDO transform(TDeviceInfoInDTO deviceInfoInDTO) {
        if (Objects.isNull(deviceInfoInDTO)){
            return null;
        }

        TDeviceInfoDO tDeviceInfoDO = BeanUtils.copyProperties(deviceInfoInDTO, TDeviceInfoDO.class);

        tDeviceInfoDO.setId(deviceInfoInDTO.getDeviceInfoId());

        if (Objects.nonNull(deviceInfoInDTO.getDeviceRent())){
            tDeviceInfoDO.setDeviceRent(MoneyUtils.yuan2fen(deviceInfoInDTO.getDeviceRent()));
        }

        if (Objects.nonNull(deviceInfoInDTO.getEquipmentDeposit())){
            tDeviceInfoDO.setEquipmentDeposit(MoneyUtils.yuan2fen(deviceInfoInDTO.getEquipmentDeposit()));
        }

        return tDeviceInfoDO;
    }
}
